<template>
 <a-modal
    :visible="visible"
    :title="t('info')"
    :cancelText="t('cancel')"
    :okText="t('submit')"
    @ok="submit"
    @cancel="cancel(false)"
  >
    <a-form
       ref="formRef"
      :model="formState"
      :rules="formRules"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >    
     
      <a-form-item ref="login_name" :label="t('login name')" name="login_name">
        <a-input disabled v-model:value="formState.login_name" />
      </a-form-item> 
      <a-form-item  ref="user_name" :label="t('username')" name="user_name">
        <a-input disabled v-model:value="formState.user_name" />
      </a-form-item>
        <a-form-item :label="t('status')" name="status">
        <a-switch disabled :checkedValue="1" :unCheckedValue="0" :checkedChildren="t('open')" :unCheckedChildren="t('close')" v-model:checked="formState.status" />
      </a-form-item>
  <a-form-item   ref="phone" :label="t('phone')" name="phone">
        <a-input disabled v-model:value="formState.phone" />
      </a-form-item>
      <a-form-item  ref="email" :label="t('email')" name="email">
        <a-input disabled v-model:value="formState.email" />
      </a-form-item> 
      <a-form-item   ref="create_time" :label="t('create_time')" name="create_time">
        <a-input disabled v-model:value="formState.create_time" />
      </a-form-item>
      <a-form-item   ref="update_time" :label="t('create_time')" name="update_time">
        <a-input disabled v-model:value="formState.update_time"/>
      </a-form-item>
     
    </a-form>
  </a-modal>
</template>
<script>
import { useI18n  } from "vue-i18n";
import { message } from 'ant-design-vue'; 
import { defineComponent, reactive, ref, toRaw, watch } from "vue";
export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
    record: {
      type: Object
    }
  },
  emit: ["close"],
  setup(props, context) {
    const { t } = useI18n();
    const state = reactive({ 
      depts: [], 
    })
    
    const formRef = ref();
    
    const formState = reactive({
      sort: 0,
      enable: true,
    });

    watch(props,(props) => {
      formState.login_name = props.record.login_name;
      formState.user_name = props.record.user_name;
      formState.status = props.record.status;
      formState.phone = props.record.phone;
      formState.email = props.record.email;
      formState.create_time = props.record.create_time; 
      formState.update_time = props.record.update_time; 
    })

    const formRules = { 
    };

    const submit = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };

    const cancel = (e) => {
      formRef.value.resetFields();
      context.emit("close", false);
    };    

    return {
      t,
      state,
      submit,
      cancel,
      formRef,
      formState,
      formRules,
      
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    };
  },
});
</script>